package com.fengchao.api.controller.v1;

import com.alibaba.fastjson.JSON;
import com.fengchao.api.config.Constant;
import com.fengchao.api.service.BciService;
import com.fengchao.api.service.CfgService;
import com.fengchao.api.service.TrcService;
import com.fengchao.api.service.UsrService;
import com.fengchao.model.cfg.CfgRegion;
import com.fengchao.model.cfg.CfgSongType;
import com.fengchao.model.entity.comm.CustomBizException;
import com.fengchao.model.entity.comm.Message;
import com.fengchao.model.entity.comm.ResponseParameter;
import com.fengchao.model.usr.UsrAppDevice;
import com.fengchao.model.usr.UsrInfo;
import com.fengchao.model.usr.UsrSharedMessageOptIn;
import com.fengchao.model.usr.UsrTicketInspector;
import com.fengchao.util.common.CommonValidator;
import com.fengchao.util.encrypt.Md5;
import com.fengchao.util.net.IpUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.fengchao.api.config.Constant.*;

/**
 * 用户模块
 * Created by wangnian on 2016/6/2.
 */
@RequestMapping("/v1/usr")
@RestController
public class UsrController {

    @Autowired
    private UsrService usrService;
    @Autowired
    private TrcService trcService;
    @Autowired
    private CfgService cfgService;
    @Autowired
    private BciService bciService;


    private Logger logger = LoggerFactory.getLogger(UsrController.class);

    /**
     * 首次打开app
     *
     * @param deviceType
     * @param deviceUniqueToken
     * @param deviceModel
     * @param deviceSystem
     * @return
     */
    @ApiOperation(value = "(APP)打开APP接口", notes = "返回参数</br>成功:</br>{status:SUCCESS, message:登陆成功}" +
            "</br>失败：</br>{status:FAILURE, message:登陆失败}")
    @RequestMapping(value = "/record", method = RequestMethod.POST)
    public ResponseParameter record(HttpServletRequest httpServletRequest,
                                    @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                    @ApiParam(value = "(必填)设备类型,IOS/ANDROID", required = true) @RequestHeader(required = false) String deviceType,
                                    @ApiParam(value = "(必填)设备唯一token", required = true) @RequestHeader(required = false) String deviceUniqueToken,
                                    @ApiParam(value = "(必填)设备型号", required = true) @RequestHeader(required = false) String deviceModel,
                                    @ApiParam(value = "(必填)设备系统版本", required = true) @RequestHeader(required = false) String deviceSystem,
                                    @ApiParam(value = "(必填)APP版本", required = true) @RequestHeader(required = false) Integer appVersion,
                                    @ApiParam(value = "(必填)渠道code", required = true) @RequestHeader(required = false) String channel_code) {
        logger.info("打开APP接口请求参数= token:{},deviceType:{},deviceUniqueToken:{},deviceModel:{},deviceSystem:{},appVersion:{}，channel_code:{}", token, deviceType, deviceUniqueToken, deviceModel, deviceSystem, appVersion, channel_code);
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, LOGIN_FAILURE);
        UsrAppDevice usrAppDevice = usrService.findBydeviceUniqueToken(deviceUniqueToken);
        if (usrAppDevice == null) {//不存在设备表
            //存设备表
            usrAppDevice = usrService.recordDevice(deviceType, deviceUniqueToken, deviceModel, deviceSystem);
            logger.info("保存设备= deviceType:{},deviceUniqueToken:{},deviceModel:{},deviceSystem:{}", deviceType, deviceUniqueToken, deviceModel, deviceSystem);
            //记录用户设备和渠道记录表
            if (channel_code != null) {
                usrService.recordChannel(channel_code, usrAppDevice.getId());
                logger.debug("记录设备和渠道= code:{},deviceId:{}", channel_code, usrAppDevice.getId());
            }
            //记录用户打开app信息
            boolean bool = trcService.record(token, usrAppDevice.getId(), appVersion, channel_code, IpUtil.getLocalIp(httpServletRequest), true);
            if (bool) {
                logger.debug("记录打开APP信息= token:{}, device:{}, appVersion:{}, channel_code:{},ip:{},isFirstOpen:{}", token, usrAppDevice.getId(), appVersion, channel_code, IpUtil.getLocalIp(httpServletRequest), true);
            }
        } else {
            //记录用户打开app信息
            boolean bool = trcService.record(token, usrAppDevice.getId(), appVersion, channel_code, IpUtil.getLocalIp(httpServletRequest), false);
            if (bool) {
                logger.debug("记录打开APP信息= token:{}, device:{}, appVersion:{}, channel_code:{},ip:{},isFirstOpen:{}", token, usrAppDevice.getId(), appVersion, channel_code, IpUtil.getLocalIp(httpServletRequest), false);
            }
        }
        if (CommonValidator.isStringsNotNull(token) && !"0".equals(token)) {//传递是token
            Integer userId = usrService.getUserId(APP, token, false);
            if (CommonValidator.isStringsNotNull(userId)) {
                responseParameter.setStatus(Message.SUCCESS);
                responseParameter.setMessage(LOGIN_SUCCESS);
                logger.info("打开APP接口响应参数= {}", JSON.toJSON(responseParameter));
                return responseParameter;
            }
        }
        logger.info("打开APP接口响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ApiOperation(value = "登录接口", notes = "返回参数 </br>成功:</br> {status:SUCCESS, message:登陆成功}" +
            "</br>失败:</br>{status:FAILURE, message:用户名和密码无效} </br> " +
            "{status:FAILURE, message:参数不全} 缺少必须字段 </br> " +
            "{status:FAILURE, message:该手机号未注册} </br> " +
            "{status:FAILURE, message:用户名和密码无效} </br>" +
            " {status:FAILURE, message:当前用户被锁定,请联系管理员}")
    public ResponseParameter login(HttpServletRequest httpServletRequest,
                                   @ApiParam(value = "(WEB必填)User-Agent,WEB浏览器自带该参数,不需要传递") @RequestHeader(required = false) String deviceCode,
                                   @ApiParam(value = "(APP必填)消息推送的messageToken,友盟推送单条消息的唯一标示", required = false) @RequestHeader(required = false) String messageToken,
                                   @ApiParam(value = "(APP必填)设备唯一token", required = false) @RequestHeader(required = false) String deviceUniqueToken,
                                   @ApiParam(value = "(APP/WEB必填)类型,APP/WEB", required = true) @RequestHeader(required = true) String type,
                                   @ApiParam(value = "(APP/WEB必填)手机号码", required = true) @RequestParam(required = true) String mobile,
                                   @ApiParam(value = "(APP/WEB必填)密码", required = true) @RequestParam(required = true) String password) {
        logger.info("登录接口请求参数= messageToken:{},deviceUniqueToken:{},deviceCode:{},type:{},mobile:{},password:{}", messageToken, deviceUniqueToken, deviceCode, type, mobile, password);
        if (!(Constant.APP.equals(type) || Constant.WEB.equals(type))) {
            logger.info("登录接口响应参数=type错误 type:{}", type);
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        if (!CommonValidator.isStringsNotNull(mobile) || !CommonValidator.isStringsNotNull(password)) {
            logger.info("登录接口响应参数=用户名或密码为空 mobile:{},password:{}", mobile, password);
            throw new CustomBizException((PASSWORD_INVALID));
        }
        ResponseParameter responseParameter = usrService.login(mobile, password, IpUtil.getLocalIp(httpServletRequest), type, deviceUniqueToken, messageToken, deviceCode);
        logger.info("登录接口响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)注册接口", notes = "返回参数</br>成功:</br>{status:SUCCESS, message:注册成功}</br>" +
            "失败:</br>{status:FAILURE, message:参数不全}</br>{status:FAILURE, message:验证码错误}</br>" +
            "{status:FAILURE, message:该手机号已注册} </br>{status:FAILURE, message:注册失败}")
    public ResponseParameter register(HttpServletRequest httpServletRequest,
                                      @ApiParam(value = "(WEB必填)User-Agent,WEB浏览器自带该参数,不需要传递") @RequestHeader(required = false) String deviceCode,
                                      @ApiParam(value = "(APP必填)消息推送的messageToken,友盟推送单条消息的唯一标示") @RequestHeader(required = false) String messageToken,
                                      @ApiParam(value = "(APP必填)设备唯一token") @RequestHeader(required = false) String deviceUniqueToken,
                                      @ApiParam(value = "(APP/WEB必填)APP或者WEB", required = true) @RequestHeader(required = false) String type,
                                      @ApiParam(value = "(APP/WEB必填)手机号码", required = true) @RequestParam(required = false) String mobile,
                                      @ApiParam(value = "(APP/WEB必填)密码", required = true) @RequestParam(required = false) String password,
                                      @ApiParam(value = "(APP/WEB必填)验证码", required = true) @RequestParam(required = false) String captcha,
                                      @ApiParam(value = "(APP/WEB必填)注册来源   IOS  ANDROID PC  WECHAT", required = true) @RequestParam(required = false) String source,
                                      @ApiParam(value = "(APP/WEB必填)注册渠道", required = true) @RequestParam(required = false) String channel) {
        logger.info("注册接口请求参数= type:{},messageToken:{},deviceUniqueToken:{},deviceCode:{} mobile:{},password:{},captcha:{},source:{},channel:{}", type, messageToken, deviceUniqueToken, deviceCode, mobile, password, captcha, source, channel);
        if (!CommonValidator.isStringsNotNull(type, mobile, password, captcha, source, channel)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        if (!usrService.checkSms(mobile, captcha)) {
            logger.info("注册接口响应参数= 验证码失败: captcha:{}", captcha);
            throw new CustomBizException(CAPTCHA_INVALID);
        }
        ResponseParameter responseParameter = usrService.register(type, messageToken, deviceUniqueToken, deviceCode, mobile, password, source, channel, IpUtil.getLocalIp(httpServletRequest));
        logger.info("注册接口响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/sendSms/{smsType}", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)发送短信接口", notes = "返回参数:</br>成功: </br>{status: SUCCESS, </br>message: 发送成功,</br>data:{</br>&nbsp;&nbsp;endTime: 112 (短信时间倒计时)</br>&nbsp;}</br>}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 该手机已注册}</br>{status: FAILURE, message: 发送失败}")
    public ResponseParameter sendSms(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                     @ApiParam(value = "(APP/WEB必填)短信类型(1 注册,2 找回密码)", required = true) @PathVariable(value = "smsType") Integer smsType,
                                     @ApiParam(value = "(APP/WEB必填)手机号码", required = true) @RequestParam(required = true) String mobile) {
        logger.info("发送短信请求参数= type:{} smsType:{} mobile:{}", type, smsType, mobile);
        if (!CommonValidator.isStringsNotNull(type, mobile, smsType)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        // TODO: 2016/6/6  解密mobile
        // byte[] str=  Aes.encrypt(mobile,"");
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, SEND_FAILURE);
        if (smsType == 1) {//如果是注册 检查一下手机号是否注册
            //效验手机号是否存在
            UsrInfo usrInfo = usrService.findMobile(mobile);
            if (usrInfo != null) {
                responseParameter.setMessage(YES_REGISTER);
                logger.info("发送短信响应参数= {}", JSON.toJSON(responseParameter));
                return responseParameter;
            }
        }
        if (smsType == 1 || smsType == 2) {//如果smsType传的是正确
            responseParameter = usrService.sendSms(mobile, "101952");
            logger.info("发送短信响应参数= {}", JSON.toJSON(responseParameter));
            return responseParameter;
        }
        logger.info("发送短信响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/bindMobile", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)绑定手机号码", notes = "返回参数</br>成功:" +
            "</br>{status:SUCCESS, message:绑定成功}" +
            "</br>重新登录:</br>{status:RELOGIN,message:Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}" +
            "</br>{status:FAILURE, message:验证码错误}" +
            "</br>{status:FAILURE, message:绑定失败，已绑定手机号码}")
    public ResponseParameter bindMobile(@ApiParam(value = "(APP/WEB必填)类型,APP/WEB", required = true) @RequestHeader String type,
                                        @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                        @ApiParam(value = "(APP/WEB必填)手机号", required = true) @RequestParam String mobile,
                                        @ApiParam(value = "(APP/WEB必填)密码", required = true) @RequestParam String password,
                                        @ApiParam(value = "(APP/WEB必填)验证码", required = true) @RequestParam String captcha) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, BIND_SUCCESS);
        logger.info("绑定手机号码请求参数= type：{},token:{}，mobile:{},password:{},captcha:{}", type, token, mobile, password, captcha);
        if (!CommonValidator.isStringsNotNull(type, token, mobile, password, captcha)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        if (!usrService.checkSms(mobile, captcha)) {
            logger.info("绑定手机号码响应参数= 验证码失败: captcha:{}", captcha);
            throw new CustomBizException(CAPTCHA_INVALID);
        }
        //查询手机号是否存在并没有绑定手机号码
        UsrInfo usrInfo = usrService.findUsrInfo(userId);
        if (usrInfo != null && usrInfo.getMobile() == null) {
            UsrInfo usrInfo1 = new UsrInfo();
            usrInfo1.setId(usrInfo.getId());
            usrInfo1.setMobile(mobile);
            usrInfo1.setPassword(Md5.encoderToString(password, Constant.MD5_KEY));
            usrService.updateUerInfo(usrInfo1);
        } else {
            responseParameter = new ResponseParameter(Message.FAILURE, BIND_FAILURE_PHONE);
        }
        logger.info("响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updatePassword", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP/WEB)修改密码", notes = "返回参数: </br>成功:</br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br> {status: FAILURE, message: 参数不全} </br>{status: FAILURE, message: 更新失败}</br>{status: FAILURE, message: 旧密码无效}")
    public ResponseParameter updatePassword(@ApiParam(value = "(APP/WEB必填)APP或者WEB", required = true) @RequestHeader String type,
                                            @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                            @ApiParam(value = "(APP/WEB必填)老密码", required = true) @RequestParam String oldPassword,
                                            @ApiParam(value = "(APP/WEB必填)新密码", required = true) @RequestParam String newPassword) {
        logger.info("修改密码请求参数= token:{}，oldPassword,newPassword", token, oldPassword, newPassword);
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        if (!CommonValidator.isStringsNotNull(token, type, oldPassword, newPassword)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = usrService.findUsrInfo(userId);
        if (usrInfo != null && usrInfo.getPassword().equals(Md5.encoderToString(oldPassword, Constant.MD5_KEY))) {
            usrInfo.setId(userId);
            usrInfo.setPassword(Md5.encoderToString(newPassword, Constant.MD5_KEY));
            responseParameter = usrService.updateUerInfo(usrInfo);//根据token修改密码
        } else {
            responseParameter.setMessage(OLDPASSWORD_INVALID);
        }
        logger.info("修改密码响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/setPassword", method = RequestMethod.PATCH)
    @ApiOperation(value = "(WEB/APP)忘记密码", notes = "返回参数</br> 成功：</br> {status : SUCCESS, message: 更新成功} </br> 重新登录: </br> {status：RELOGIN, message: Token失效} </br>" +
            "失败：</br>  {status : FAILURE, message: 参数不全} </br> {status : FAILURE, message: 更新失败}  </br> {status : FAILURE, message: 旧密码无效}")
    public ResponseParameter setPassword(@ApiParam(value = "(APP/WEB必填)手机号码", required = true) @RequestParam String mobile,
                                         @ApiParam(value = "(APP/WEB必填)验证码", required = true) @RequestParam String captcha,
                                         @ApiParam(value = "(APP/WEB必填)新密码", required = true) @RequestParam String password) {
        logger.info("忘记密码请求参数= mobile:{}，captcha:{},passWord:{}", mobile, captcha, password);
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        if (!CommonValidator.isStringsNotNull(mobile, captcha, password)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        if (!usrService.checkSms(mobile, captcha)) {
            logger.info("忘记密码响应参数= 验证码失败: captcha:{}", captcha);
            throw new CustomBizException(CAPTCHA_INVALID);
        }
        UsrInfo usrInfo1 = usrService.findMobile(mobile);
        if (usrInfo1 != null) {
            UsrInfo usrInfo = new UsrInfo();
            usrInfo.setId(usrInfo1.getId());
            usrInfo.setPassword(Md5.encoderToString(password, Constant.MD5_KEY));
            responseParameter = usrService.updateUerInfo(usrInfo);//更改密码
        }
        logger.info("忘记密码响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updateUser", method = RequestMethod.PATCH)
    @ApiOperation(value = "(WEB)修改用户信息", notes = "返回参数:</br>成功: </br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateUser(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader(required = false) String type,
                                        @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                        @ApiParam(value = "新昵称") @RequestParam(required = false) String nickName,
                                        @ApiParam(value = "地区id") @RequestParam(required = false) Integer regionId,
                                        @ApiParam(value = "头像") @RequestParam(required = false) StringBuffer base64Str,
                                        @ApiParam(value = "性别") @RequestParam(required = false) String sex,
                                        @ApiParam(value = "个新签名") @RequestParam(required = false) String personalSignature,
                                        @ApiParam(value = "喜欢的曲风id") @RequestParam(required = false) String songStyle) {
        logger.info("修改用户信息请求参数= token:{} nickName:{},regionId:{},sex:{}，personalSignature:{},songStyle:{}", token, nickName, regionId, sex, personalSignature, songStyle);
        if (!Constant.WEB.equals(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        if (!CommonValidator.isStringsNotNull(token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = new UsrInfo();
        usrInfo.setId(userId);
        if (CommonValidator.isStringsNotNull(nickName)) {
            usrInfo.setNickname(nickName);
        }
        if (CommonValidator.isStringsNotNull(regionId)) {
            //区 县
            CfgRegion cfgRegion = cfgService.getCfgRegionByid(regionId);
            if (cfgRegion != null) {
                //市
                CfgRegion cfgRegion1 = cfgService.getCfgRegionByid(cfgRegion.getPid());
                usrInfo.setDefaultCity(cfgRegion1.getName() + " " + cfgRegion.getName());
                usrInfo.setDistrictId(regionId);
            }
        }
        if (CommonValidator.isStringsNotNull(sex)) {
            usrInfo.setSex(sex);
        }
        if (CommonValidator.isStringsNotNull(personalSignature)) {
            usrInfo.setPersonalSignature(personalSignature);
        }
        if (CommonValidator.isStringsNotNull(songStyle)) {
            //将 1;2;3;3 换成json 3;4
            String[] styleIds = songStyle.split(";");
            List<CfgSongType> list = new ArrayList<>();
            for (String styleId : styleIds) {
                CfgSongType cfgSongType = cfgService.getCfgSongTypeById(Integer.valueOf(styleId));
                if (cfgSongType != null) {
                    list.add(cfgSongType);
                }
            }
            usrInfo.setFavouriteSongStyle(JSON.toJSONString(list));
        }
        if (CommonValidator.isStringsNotNull(base64Str)) {
            String iconLocation = usrService.uploadHeadIcon(userId, base64Str);
            if (CommonValidator.isStringsNotNull(iconLocation)) {
                usrInfo.setHeadIcon(iconLocation);
            }
        }
        ResponseParameter responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
        logger.info("修改用户信息响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/updateNickname", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP)修改昵称", notes = "返回参数: </br>成功: </br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateNickName(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader String type,
                                            @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                            @ApiParam(value = "(必填)新昵称", required = true) @RequestParam String nickName) {
        logger.info("修改昵称请求参数= token:{}，nickName:{}", token, nickName);
        if (!CommonValidator.isStringsNotNull(token, nickName)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = new UsrInfo();
        usrInfo.setId(userId);
        usrInfo.setNickname(nickName);
        ResponseParameter responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
        logger.info("修改昵称响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updatePersonalSignature", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP)修改个性签名", notes = "返回参数: </br>成功:</br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br> {status: FAILURE, message: 参数不全} </br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updatePersonalSignature(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader(required = false) String type,
                                                     @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                                     @ApiParam(value = "(必填)个性签名", required = true) @RequestParam String personalSignature) {
        logger.info("修改个性签名请求参数= token:{}，personalSignature:{}", token, personalSignature);
        if (!CommonValidator.isStringsNotNull(token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = new UsrInfo();
        usrInfo.setId(userId);
        usrInfo.setPersonalSignature(personalSignature);
        ResponseParameter responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
        logger.info("修改个性签名响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updateRegion", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP)修改城市地区", notes = "返回参数: </br>成功:</br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br> {status: FAILURE, message: 参数不全} </br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateRegion(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader(required = false) String type,
                                          @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                          @ApiParam(value = "(必填)城市  上海市 虹口区", required = true) @RequestParam String region) {
        logger.info("修改城市请求参数= type:{} token:{}，region:{} ", token, region);
        if (!CommonValidator.isStringsNotNull(type, token, region)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = new UsrInfo();
        usrInfo.setId(userId);
        usrInfo.setDefaultCity(region);
        ResponseParameter responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
        logger.info("修改城市响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updateSex", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP)修改性别", notes = "返回参数: </br>成功: </br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br> {status: FAILURE, message: 参数不全} </br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateSex(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader String type,
                                       @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                       @ApiParam(value = "(必填)性别", required = true) @RequestParam String sex) {
        logger.info("修改性别请求参数= token:{}，city:{}", token, sex);
        if (!CommonValidator.isStringsNotNull(type, token, sex)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        UsrInfo usrInfo = new UsrInfo();
        usrInfo.setId(userId);
        usrInfo.setSex(sex);
        ResponseParameter responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
        logger.info("修改性别响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updateHeadIcon", method = RequestMethod.POST)
    @ApiOperation(value = "(APP)修改头像", notes = "返回参数: </br>成功: </br>{status: SUCCESS, message: 更新成功,</br>}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateHeadIcon(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader(required = false) String type,
                                            @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                            @ApiParam(value = "(必填)头像文件（最大3M,超过之后返回信息）, required = true") @RequestParam MultipartFile file) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        logger.info("修改头像请求参数= token:{}，file:{}", token, file);
        if (!CommonValidator.isStringsNotNull(token, type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        String iconLocation = null;
        if (!file.isEmpty()) {
            iconLocation = usrService.uploadHeadIcon(userId, file);
        }
        if (iconLocation != null) {
            UsrInfo usrInfo = new UsrInfo();
            usrInfo.setId(userId);
            usrInfo.setHeadIcon(iconLocation);
            responseParameter = usrService.updateUerInfo(usrInfo);//更新用户资料
            logger.info("修改头像响应参数={}", JSON.toJSON(responseParameter));
            return responseParameter;
        }
        logger.info("修改头像响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/favorite/{favoriteType}/{foreignId}/{operationType}", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)收藏接口", notes = "描述: </br>对歌曲、专辑、众筹的收藏和取消收藏的接口" +
            "</br></br>返回参数" +
            "</br>成功: </br>{status: SUCCESS,</br> message: 更新成功, " +
            "</br> &nbsp;data:{</br>&nbsp;&nbsp;isFavorite: 1(是否收藏 1: 收藏 0: 取消收藏)" +
            "</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}" +
            "</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter favorite(@ApiParam(value = "(APP/WEB必填)类型,APP/WEB", required = true) @RequestHeader String type,
                                      @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                      @ApiParam(value = "(APP/WEB必填)收藏的对象,SONGS(歌曲)/AIBUM(专辑)/CROWDFUNDING（众筹）/PERFORMANCE（演出） ", required = true) @PathVariable(value = "favoriteType") String favoriteType,
                                      @ApiParam(value = "(APP/WEB必填)对应的ID", required = true) @PathVariable(value = "foreignId") Integer foreignId,
                                      @ApiParam(value = "(APP/WEB必填)操作的类型 0：取消收藏/1：收藏", required = true) @PathVariable(value = "operationType") Integer operationType) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        logger.info("收藏请求参数= type：{},token:{},favoriteType:{},foreignId:{}，operationType:{}", type, token, favoriteType, foreignId, operationType);
        if (!CommonValidator.isStringsNotNull(type, token, favoriteType, foreignId, operationType)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean bool = usrService.updateFavorite(favoriteType, foreignId, operationType, userId);
        if (bool) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(UPDATATE_SUCCESS);
            Map<Object, Object> map = new HashMap<>();
            map.put("isFavorite", operationType);
            responseParameter.setData(map);
        }
        logger.info("收藏响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/focus/{artistId}/{operationType}", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)关注", notes = "返回参数" +
            "</br>成功: </br>{status: SUCCESS, </br>message: 更新成功, " +
            "</br> data:{</br> &nbsp;&nbsp; isFocus : 1(是否关注 1:关注 0:取消关注)" +
            "</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}" +
            "</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter focus(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                   @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                   @ApiParam(value = "(APP/WEB必填)艺人id", required = true) @PathVariable(value = "artistId") Integer artistId,
                                   @ApiParam(value = "(APP/WEB必填)操作的类型  0：取消关注，1：关注", required = true) @PathVariable(value = "operationType") Integer operationType) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        logger.info("关注请求参数= type：{},token:{},artistId:{},operationType:{}", type, token, artistId, operationType);
        if (!CommonValidator.isStringsNotNull(type, token, artistId, operationType)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean bool = usrService.updateFocus(artistId, userId, operationType);
        if (bool) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(UPDATATE_SUCCESS);
            Map<Object, Object> map = new HashMap<>();
            map.put("isFocus", operationType);
            responseParameter.setData(map);
        }
        logger.info("关注响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/getDeliveryAddress", method = RequestMethod.GET)
    @ApiOperation(value = "(APP/WEB)获取所有的收货地址", notes = "描述：第一个地址为默认地址</br>返回参数" +
            "</br>成功: </br>{status: SUCCESS," +
            "</br> message: 获取成功," +
            "</br> data:{</br>&nbsp;&nbsp;info:[{</br>&nbsp;&nbsp;&nbsp;&nbsp;zipCode: 11111(邮编),</br>&nbsp;&nbsp;&nbsp;&nbsp;isDefault: 1(是否默认 1: 默认地址 0: 不是默认地址 ),</br>&nbsp;&nbsp;&nbsp;&nbsp;other: === (剩余部分地址),</br>&nbsp;&nbsp;&nbsp;&nbsp;address: 北京北京市东城区=== (详细地址),</br>&nbsp;&nbsp;&nbsp;&nbsp;province: 北京(省份),</br>&nbsp;&nbsp;&nbsp;&nbsp;city: 北京市(城市),</br>&nbsp;&nbsp;&nbsp;&nbsp;road: ===街道(道路),</br>&nbsp;&nbsp;&nbsp;&nbsp;person: 张三(收件人姓名),</br>&nbsp;&nbsp;&nbsp;&nbsp;district: 东城区(行政区),</br>&nbsp;&nbsp;&nbsp;&nbsp;mobile: 11111111(收货人联系电话),</br>&nbsp;&nbsp;&nbsp;&nbsp;addressId: 11(地址Id),</br>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;}</br>], </br>&nbsp;&nbsp;postage: 11111(邮费)</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, meassage: Token失效}" +
            "</br>失败: </br>{status:FAILURE, message: 参数不全}" +
            "</br>{status:FAILURE, message: 获取失败}")
    public ResponseParameter getDeliveryAddress(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, GET_FAILURE);
        logger.info("获取收货地址请求参数= type：{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> addressList = usrService.getAddressList(userId);
        responseParameter.setStatus(Message.SUCCESS);
        responseParameter.setMessage(GET_SUCCESS);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", addressList);
        map.put("postage", Constant.CONFIGMAP.get("postage"));//运费
        responseParameter.setData(map);
        logger.info("获取所有的收货地址响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/setDeliveryAddressDefault", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)设置默认收货地址", notes = "返回参数: </br>成功: </br>{status: SUCCESS, message: 更新成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter setDeliveryAddressDefault(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                       @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                                       @ApiParam(value = "(APP/WEB必填)地址Id", required = true) @RequestParam Integer addressId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        logger.info("设置默认收货地址请求参数= type：{},token:{},addressId={}", type, token, addressId);
        if (!CommonValidator.isStringsNotNull(type, token, addressId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Boolean bool = usrService.setAddressDefulet(userId, addressId);
        if (bool) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(UPDATATE_SUCCESS);
        }
        logger.info("设置默认收货地址响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/delectDeliveryAddress", method = RequestMethod.DELETE)
    @ApiOperation(value = "(APP/WEB)删除收货地址", notes = "返回参数" +
            "</br>成功: </br>{status: SUCCESS, meassge: 删除成功}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}" +
            "</br>{status: FAILURE, message: 删除失败}")
    public ResponseParameter delectDeliveryAddress(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                   @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                                   @ApiParam(value = "(APP/WEB必填)地址Id", required = true) @RequestParam Integer addressId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, DELETE_FAILURE);
        logger.info("删除收货地址请求参数= type：{},token:{},addressId={}", type, token, addressId);
        if (!CommonValidator.isStringsNotNull(type, token, addressId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Boolean bool = usrService.delectAddress(userId, addressId);
        if (bool) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(DELETE_SUCCESS);
        }
        logger.info("删除默认收货地址响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/setDeliveryAddress", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)添加收货地址", notes = "返回参数:</br>成功:{status: SUCCESS, </br>message: 添加成功, </br>data:{</br>&nbsp;&nbsp;id: 1(地址ID)</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 添加失败}</br>{status: FAILURE, message: 最多添加10个收货地址}")
    public ResponseParameter setDeliveryAddress(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "(APP/WEB必填)收货人", required = true) @RequestParam String person,
                                                @ApiParam(value = "(APP/WEB必填)收货人手机号码", required = true) @RequestParam String mobile,
                                                @ApiParam(value = "(APP/WEB必填)省", required = true) @RequestParam String province,
                                                @ApiParam(value = "(APP/WEB必填)市", required = true) @RequestParam String city,
                                                @ApiParam(value = "(APP/WEB必填)区", required = true) @RequestParam String district,
                                                @ApiParam(value = "(APP/WEB必填)剩余地址", required = true) @RequestParam String other,
                                                @ApiParam(value = "(APP/WEB必填)是否默认 1 默认 0不默认  ", required = true) @RequestParam Integer isDefault) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, ADD_FAILURE);
        logger.info("添加收货地址请求参数= type：{},token:{} person:{},mobile:{},province:{},city:{},district:{},isDefault:{}", type, token, person, mobile, province, city, district, isDefault);
        if (!CommonValidator.isStringsNotNull(type, token, person, mobile, province, city, district, other, isDefault)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Integer addressId = usrService.addAddress(userId, person, mobile, province, city, district, other, isDefault);
        if (addressId != null) {
            Map<Object, Object> resultMap = new HashMap<>();
            resultMap.put("id", addressId);
            responseParameter.setData(resultMap);
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(ADD_SUCCESS);
        } else {
            responseParameter.setMessage(ADD_ADDRESS_MAX);
        }
        logger.info("添加收货地址响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/updateDeliveryAddress", method = RequestMethod.PATCH)
    @ApiOperation(value = "(APP/WEB)修改收货地址", notes = "返回参数:</br>成功: </br>{status: SUCCESS, message: 更新成功}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 更新失败}")
    public ResponseParameter updateDeliveryAddress(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                   @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                                   @ApiParam(value = "(APP/WEB必填)地址ID", required = true) @RequestParam Integer addressId,
                                                   @ApiParam(value = "(APP/WEB必填)收货人", required = true) @RequestParam String person,
                                                   @ApiParam(value = "(APP/WEB必填)收货人手机号码", required = true) @RequestParam String mobile,
                                                   @ApiParam(value = "(APP/WEB必填)省", required = true) @RequestParam String province,
                                                   @ApiParam(value = "(APP/WEB必填)市", required = true) @RequestParam String city,
                                                   @ApiParam(value = "(APP/WEB必填)区", required = true) @RequestParam String district,
                                                   @ApiParam(value = "(APP/WEB必填)剩余地址", required = true) @RequestParam String other,
                                                   @ApiParam(value = "(APP/WEB必填)是否默认 1 默认 0不默认  ", required = true) @RequestParam Integer isDefault) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, UPDATATE_FAILURE);
        logger.info("修改收货地址请求参数= type：{},token:{} addressId:{} person:{},mobile:{},province:{},city:{},district:{},other:{},isDefault:{}", type, token, addressId, person, mobile, province, city, district, other, isDefault);
        if (!CommonValidator.isStringsNotNull(type, token, person, mobile, province, city, district, other, isDefault)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Boolean bool = usrService.updateAddress(userId, addressId, person, mobile, province, city, district, other, isDefault);
        if (bool) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(UPDATATE_SUCCESS);
        }
        logger.info("修改收货地址响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
    @ApiOperation(value = "(APP/WEB)获取用户信息", notes = "返回数据</br>成功:</br>用户类型为粉丝</br>{status: SUCCESS, </br>message: 获取成功, </br>data：{</br>&nbsp;&nbsp;headIcon: http://swarm-dev.b0.upaiyun.com/usr/user_icon/1469683959883.png &nbsp;(头像地址)</br>&nbsp;&nbsp;user_type： FANS(用户分类,默认：FANS(粉丝),FANS(粉丝)/ARTIST(艺人)/ORGANIZER(主办方)/FIELD_PROVIDER(场地提供))</br>&nbsp;&nbsp;personalSignature: 哈哈哈(个性签名)," +
            "</br>&nbsp;&nbsp;city: 上海(城市)</br>&nbsp;&nbsp;sex: 男(性别)</br>&nbsp;&nbsp;mobile: 1111111(手机号码)</br>&nbsp;&nbsp;nickName: 千寻(昵称)</br>&nbsp;&nbsp;style: [{id: 1(曲风的ID), typeName: 摇滚(曲风种类的名字)}] 喜欢的曲风</br>&nbsp;}</br>}" +
            "</br></br>用户类型为艺人</br>{status: SUCCESS, </br>message: 获取成功, </br>data：{</br>&nbsp;&nbsp;headIcon: http://swarm-dev.b0.upaiyun.com/usr/user_icon/1469683959883.png &nbsp;(头像地址)</br>&nbsp;&nbsp;user_type： FANS(用户分类,默认：FANS(粉丝),FANS(粉丝)/ARTIST(艺人)/ORGANIZER(主办方)/FIELD_PROVIDER(场地提供))</br>&nbsp;&nbsp;personalSignature: 哈哈哈(个性签名)</br>&nbsp;&nbsp;city: 上海(城市)</br>&nbsp;&nbsp;sex: 男(性别)</br>&nbsp;&nbsp;mobile: 1111111(手机号码)" +
            "</br>&nbsp;&nbsp;nickName: 千寻(昵称)</br>&nbsp;&nbsp;style: [{id: 1(曲风的ID), typeName: 摇滚(曲风种类的名字)}] 喜欢的曲风 </br>&nbsp;&nbsp;artistInfo: {</br>&nbsp;&nbsp;&nbsp;&nbsp;id: 1(艺人ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;userId: 1(用户ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;nameEn: Tom(英文名),</br>&nbsp;&nbsp;&nbsp;&nbsp;nameZh: 张三(中文名),</br>&nbsp;&nbsp;&nbsp;&nbsp;namePy: zhangsan(艺人中文拼音)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;nameDisplay: 周杰伦(艺人展示姓名),</br>&nbsp;&nbsp;&nbsp;&nbsp;mobile: 111111(手机号码),</br>&nbsp;&nbsp;&nbsp;&nbsp;sex: 男(性别),</br>&nbsp;&nbsp;&nbsp;&nbsp;nationality: 中国(国籍)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;email: 11111@letswarm.com(邮箱),</br>&nbsp;&nbsp;&nbsp;&nbsp;headIconPc: http://swarm-dev.b0.upaiyun.com/usr/user_icon//bci/artist_head_icon_pc/921472022506906.png (PC端头像)</br>&nbsp;&nbsp;&nbsp;&nbsp;headIconApp: http://swarm-dev.b0.upaiyun.com/bci/artist_head_icon_app/111-02.png (APP端头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;musicStyle: [{id: 1(风格ID), typeName: 流行(风格类型名字)}],</br>&nbsp;&nbsp;&nbsp;&nbsp;represent: 周杰伦的床边故事(艺人代表作)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;locationType: 港澳台(所属地区，HMT：港澳台、JP：日本、KR：韩国、EA：欧美、CN：中国大陆),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistMemo: 哈哈哈哈(艺人备注),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistFileUrl: ===(艺人认证文件URL地址),</br>&nbsp;&nbsp;&nbsp;&nbsp;status: ENABLED(艺人状态，ENABLED(可用)/DISABLE(不可用)FAILURE(审核失败)),</br>&nbsp;&nbsp;&nbsp;&nbsp;lastOptTime: 1472024300000(最后一次艺人 点击查看新的赞的时间)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;lastFocusTime: 1472024300000(最后一次艺人点击查看新的关注的时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime: 1472024300000(创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;updateTime: 1472024300000(更新时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistInfo: 小公举(艺人简介),</br>&nbsp;&nbsp;&nbsp;&nbsp;detailTitleImageUrl: http://swarm-dev.b0.upaiyun.com/bci/artist_detail_title_image_url/111-03.png (app的详情页头部图片URL)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoImage: http://swarm-pdt.b0.upaiyun.com/bci/shared_video_image/dongtai_shiping.png (动态分享视频的缩约图),</br>&nbsp;&nbsp;&nbsp;&nbsp;deleted: false(是否删除艺人,true(已删除)/false(未删除)),</br>&nbsp;&nbsp;&nbsp;&nbsp;signed: 1(是否已签约, 1: 是 0: 否),</br>&nbsp;&nbsp;&nbsp;&nbsp;recommended: 1(是否被推荐 1: 是 0: 否)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br></br>用户类型为主办方</br>{status: SUCCESS, </br>message: 获取成功, </br>data：{</br>&nbsp;&nbsp;headIcon: http://swarm-dev.b0.upaiyun.com/usr/user_icon/1469683959883.png &nbsp;(头像地址)</br>&nbsp;&nbsp;user_type： FANS(用户分类,默认：FANS(粉丝),FANS(粉丝)/ARTIST(艺人)/ORGANIZER(主办方)/FIELD_PROVIDER(场地提供))</br>&nbsp;&nbsp;personalSignature: 哈哈哈(个性签名)," +
            "</br>&nbsp;&nbsp;city: 上海(城市)</br>&nbsp;&nbsp;sex: 男(性别)</br>&nbsp;&nbsp;mobile: 1111111(手机号码)</br>&nbsp;&nbsp;nickName: 千寻(昵称)</br>&nbsp;&nbsp;style: [{id: 1(曲风的ID), typeName: 摇滚(曲风种类的名字)}] 喜欢的曲风</br>&nbsp;&nbsp;organizerInfo: {</br>&nbsp;&nbsp;&nbsp;&nbsp;id: 1(主办方ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;userId: 1(用户ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;organizerName: sss(主办方名)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;organizerHead: http://swarm-dev.b0.upaiyun.com/usr/user_icon//bci/organizer_head/341468394198181.png (主办方头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;organizerType: PERSON(主办方类型,PERSON：个人, COMPANY：公司),</br>&nbsp;&nbsp;&nbsp;&nbsp;companyName: sss(主办方公司名),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactIdentity: aaa(联系人的身份证号码),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactIdentityFront: http://aaa.png (联系人身份证前面照)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;contactIdentityReverses: http://aaa.png (联系人身份证后面照),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactEmail: 12123@1sds.com(联系人邮箱),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactAddress: sss(联系人地址),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactWechat: sss(联系人微信号),</br>&nbsp;&nbsp;&nbsp;&nbsp;contactQq: sss(联系人QQ号),</br>&nbsp;&nbsp;&nbsp;&nbsp;authenticationFileUrl: http://aaa.png (认证文件地址)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;memo: 啊啊飒飒(备注),</br>&nbsp;&nbsp;&nbsp;&nbsp;status: sss(状态, ENABLED:(可用)/DISABLE(不可用)/FAILURE(审核失败)),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime: 1472809704000(创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;updateTime: 1472809707000(更新时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;deleted: false(是否删除, false: 否/true: 是)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br></br>用户类型为场地</br>{status: SUCCESS, </br>message: 获取成功, </br>data：{</br>&nbsp;&nbsp;headIcon: http://swarm-dev.b0.upaiyun.com/usr/user_icon/1469683959883.png &nbsp;(头像地址)<,/br>&nbsp;&nbsp;user_type： FANS(用户分类,默认：FANS(粉丝),FANS(粉丝)/ARTIST(艺人)/ORGANIZER(主办方)/FIELD_PROVIDER(场地提供))</br>&nbsp;&nbsp;personalSignature: 哈哈哈(个性签名)," +
            "</br>&nbsp;&nbsp;city: 上海(城市)</br>&nbsp;&nbsp;sex: 男(性别),</br>&nbsp;&nbsp;mobile: 1111111(手机号码),</br>&nbsp;&nbsp;nickName: 千寻(昵称),</br>&nbsp;&nbsp;style: [{id: 1(曲风的ID), typeName: 摇滚(曲风种类的名字)}] 喜欢的曲风,</br>&nbsp;&nbsp;bciFieldInfo: {</br>&nbsp;&nbsp;&nbsp;&nbsp;id: 1(场地ID), </br>&nbsp;&nbsp;&nbsp;&nbsp;userId: 1(用户ID), </br>&nbsp;&nbsp;&nbsp;&nbsp;fieldName: aaa(场地名称)," +
            " </br>&nbsp;&nbsp;&nbsp;&nbsp;fieldLogo: http://swarm-dev.b0.upaiyun.com/usr/user_icon//bci/field_head/871471930246207.png (场地logo地址), </br>&nbsp;&nbsp;&nbsp;&nbsp;fieldAddress: aaa(场地地址), </br>&nbsp;&nbsp;&nbsp;&nbsp;licenseNumber: aaa(营业执照号码), </br>&nbsp;&nbsp;&nbsp;&nbsp;licenseScanImageUrl: http://aaa.png(营业执照照片), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactName: aaa(联系人姓名), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactMobile: aaa(联系人手机号码), " +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;contactTelephone: aaa(联系人电话号码), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactEmail: aaa(联系人邮箱), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactAddress: aaa(联系人地址), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactWechat: aaa(联系人微信号), </br>&nbsp;&nbsp;&nbsp;&nbsp;contactQq: aaa(联系人QQ号码), </br>&nbsp;&nbsp;&nbsp;&nbsp;latitude: aaa(地址纬度坐标), </br>&nbsp;&nbsp;&nbsp;&nbsp;longitude: aaa(地址经度坐标)," +
            " </br>&nbsp;&nbsp;&nbsp;&nbsp;fieldType: aaa(场地类型, LIVEHOUSE/THEATRE：剧场/STADIUM：体育场馆/CONVERTION_CENTER：会展中心/CONCERT_HALL：音乐厅), </br>&nbsp;&nbsp;&nbsp;&nbsp;maxCapacity: aaa(场地最大可容纳人数), </br>&nbsp;&nbsp;&nbsp;&nbsp;minCapacity: aaa(场地最小启用人数), </br>&nbsp;&nbsp;&nbsp;&nbsp;fieldInfo: aaa(场地简介), </br>&nbsp;&nbsp;&nbsp;&nbsp;memo: aaa(备注), " +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;status: ENABLED(状态,ENABLED(可用)/DISABLE(不可用)/FAILURE(审核失败)), </br>&nbsp;&nbsp;&nbsp;&nbsp;createTime: 1471930247000(创建时间), </br>&nbsp;&nbsp;&nbsp;&nbsp;updateTime: 1471930247000(更新时间), </br>&nbsp;&nbsp;&nbsp;&nbsp;image: [http://aaa.png]  场地图片, </br>&nbsp;&nbsp;&nbsp;&nbsp;deleted: false(是否删除, false: 否/true: 是),</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: {status: FAILURE, message: 获取失败}</br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 没有该用户}</br>{status: FAILURE, message: 该用户不是主办方}</br>{status: FAILURE, message: 该用户不是艺人}</br>{status: FAILURE, message: 该用户不是场地}")
    public ResponseParameter getUserInfo(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                         @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, GET_FAILURE);
        logger.info("获取用户信息请求参数= type：{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<String, Object> userInfo = usrService.getUserInfo(userId);
        if (userInfo != null) {
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(GET_SUCCESS);
            HashMap<Object, Object> map = new HashMap<>();
            map.put("info", userInfo);
            responseParameter.setData(map);
        }
        logger.info("获取用户信息响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/getUserMessageList/{messageType}/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "(APP)获取用户消息列表", notes = "返回参数:</br>成功:</br>{status: SUCCESS,</br>message: 获取成功,  </br>data:{</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;id: 1(消息ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;time:1469093138000(消息创建时间)</br>&nbsp;&nbsp;&nbsp;&nbsp;title:aaa(消息的标题)</br>&nbsp;&nbsp;&nbsp;&nbsp;content:aaa(消息内容)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}")
    public ResponseParameter getUserMessageList(@ApiParam(value = "(必填)类型, APP", required = true) @RequestHeader String type,
                                                @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "(必填)消息类型 SYS(系统)，PRIVATE(个人)", required = true) @PathVariable(value = "messageType") String messageType,
                                                @ApiParam(value = "(必填)第几页", required = true) @PathVariable("page") Integer page,
                                                @ApiParam(value = "(必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取用户消息列表请求参数= type：{},token:{}, messageType:{},page:{},count:{}", type, token, messageType, page, count);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> list = usrService.getUserMessageList(userId, messageType, page, count);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", list);
        responseParameter.setData(map);
        logger.info("获取用户消息列表响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getUserMessage/{messageId}", method = RequestMethod.GET)
    @ApiOperation(value = "(APP/WEB)获取用户单条消息", notes = "返回参数:</br>成功:</br>{status: SUCCESS, </br>message: 获取成功, </br>data:{</br>&nbsp;&nbsp;info:{</br>&nbsp;&nbsp;&nbsp;time:1469093138000(消息创建时间)</br>&nbsp;&nbsp;&nbsp;title:aaa(消息的标题)</br>&nbsp;&nbsp;&nbsp;content:aaa(消息内容)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 获取失败}")
    public ResponseParameter getUserMessage(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                            @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                            @ApiParam(value = "(APP/WEB必填)消息id", required = true) @PathVariable("messageId") Integer messageId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, GET_FAILURE);
        logger.info("获取用户消息请求参数= type：{},token:{}, messageType:{}", type, token, messageId);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<String, Object> messageMap = usrService.getUserMessage(messageId, userId);
        if (messageMap != null) {
            HashMap<Object, Object> map = new HashMap<>();
            map.put("info", messageMap);
            responseParameter.setData(map);
            responseParameter.setStatus(Message.SUCCESS);
            responseParameter.setMessage(GET_SUCCESS);
        }
        logger.info("获取用户消息响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/getUserBindThirdAccount", method = RequestMethod.GET)
    @ApiOperation(value = "(APP/WEB)获取用户的第三方绑定状态", notes = "描述: 获取一个账号绑定的三方账号</br>返回数据</br>成功:</br>{status: SUCCESS,</br> message: 获取成功,</br>data: {</br>&nbsp;info: {</br>&nbsp;&nbsp;qq: 0 (QQ号码),</br>&nbsp;&nbsp;weibo: 0 (微博),</br>&nbsp;&nbsp;mobile: 0 (手机号码),</br>&nbsp;&nbsp;wechat: 0 (微信)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br>重新登录: </br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}")
    public ResponseParameter getUserBindThirdAccount(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                     @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取用户的第三方绑定状态请求参数= type：{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<String, Object> messageMap = usrService.getUserBindThirdAccount(userId);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", messageMap);
        responseParameter.setData(map);
        logger.info("获取用户的第三方绑定状态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getIdentityStatus", method = RequestMethod.GET)
    @ApiOperation(value = "(WEB)获取当前用户的身份状态", notes = "描述：获取用户的身份和状态</br>返回参数</br>成功:</br>{status: SUCCESS,</br> message: 获取成功,</br>data:{</br>&nbsp;&nbsp;info:  {</br>&nbsp;&nbsp;&nbsp;identityStatus: FIELD_PROVIDER(用户的身份,ARTIST艺人/ORGANIZER主办方/FIELD_PROVIDER场地), </br> &nbsp;&nbsp;&nbsp;status: ENABLED(身份的状态, ENABLED可用/DISABLE不可用/FAILURE审核失败)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br>重新登录：</br> {status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    public ResponseParameter getIdentityStatus(@ApiParam(value = "(必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                               @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取当前用户的身份状态请求参数= type:{},token:{} ", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<Object, Object> identityStatusMap = bciService.getIdentityStatus(userId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", identityStatusMap);
        responseParameter.setData(map);
        logger.info("获取当前用户的身份状态响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/thirdAccountLogin", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)第三方账号登录接口", notes = "返回参数:</br>成功: </br>{status: SUCCESS, </br> message: 登陆成功, </br>data: {</br>&nbsp;&nbsp;token: 9bab3dcb-d017-426e-a8ee-0b0e17b22925(用户使用APP/WEB的token值)</br>&nbsp;}</br>}" +
            "</br>失败: </br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 登录失败}")
    public ResponseParameter thirdAccountLogin(HttpServletRequest httpServletRequest,
                                               @ApiParam(value = "(WEB必填)User-Agent,WEB浏览器自带该参数,不需要传递") @RequestHeader(required = false, value = "User-Agent") String deviceCode,
                                               @ApiParam(value = "(APP必填)消息推送的messageToken", required = false) @RequestHeader(required = false) String messageToken,
                                               @ApiParam(value = "(APP必填)设备唯一token", required = false) @RequestHeader(required = false) String deviceUniqueToken,
                                               @ApiParam(value = "(APP/WEB必填)APP或者WEB", required = true) @RequestHeader(required = true) String type,
                                               @ApiParam(value = "(APP/WEB必填)公开ID, qq/wechat/weibo的OpenID", required = true) @RequestParam(required = true) String openId,
                                               @ApiParam(value = "昵称", required = false) @RequestParam(required = false) String nickName,
                                               @ApiParam(value = "性别", required = false) @RequestParam(required = false) String sex,
                                               @ApiParam(value = "头像", required = false) @RequestParam(required = false) String headIcon,
                                               @ApiParam(value = "(APP/WEB必填)第三方登录类型 (QQ,WEIBO,WECHAT)", required = true) @RequestParam(required = true) String thirdAccountType,
                                               @ApiParam(value = "注册来源   IOS  ANDROID PC  WECHAT", required = true) @RequestParam(required = false) String source,
                                               @ApiParam(value = "注册渠道 ", required = true) @RequestParam(required = false) String channel) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, LOGIN_SUCCESS);
        logger.info("第三方登录接口请求参数= messageToken:{},deviceUniqueToken:{},deviceCode:{},type:{},openId:{},nickName:{},sex:{},headIcon:{},thirdAccountType:{}", messageToken, deviceUniqueToken, deviceCode, type, openId, nickName, sex, headIcon, thirdAccountType);
        if (!(Constant.APP.equals(type) || Constant.WEB.equals(type))) {
            logger.info("第三方登录接口响应参数=type错误 type:{}", type);
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        if (!CommonValidator.isStringsNotNull(openId, thirdAccountType)) {
            logger.info("第三方登录接口响应参数= openId:{},thirdAccountType:{}", openId, thirdAccountType);
            throw new CustomBizException((LOGIN_FAILURE));
        }
        String token = usrService.loginByUserbindThirdAccount(nickName, sex, headIcon, openId, thirdAccountType, httpServletRequest.getRemoteAddr(), type, deviceUniqueToken, messageToken, deviceCode, source, channel);
        if (CommonValidator.isStringsNotNull(token)) {
            HashMap<Object, Object> map = new HashMap<>();
            map.put("token", token);
            responseParameter.setData(map);
        } else {
            responseParameter.setMessage(LOGIN_FAILURE);
            responseParameter.setStatus(Message.FAILURE);
        }
        logger.info("第三方登录接口响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/bindThirdAccount", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)绑定第三方账号", notes = "返回参数" +
            "</br>成功:</br>{status: SUCCESS, message: 绑定成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status: FAILURE, messsage: 参数不全}" +
            "</br>{status: FAILURE, messsage: 绑定失败，已经绑定了其他账号}")
    public ResponseParameter bindThirdAccount(@ApiParam(value = "(APP/WEB必填)类型，APP/WEB", required = true) @RequestHeader(required = true) String type,
                                              @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                              @ApiParam(value = "(APP/WEB必填)OpenID", required = true) @RequestParam(required = true) String openId,
                                              @ApiParam(value = "(APP/WEB必填)第三方登录类型，QQ/WEIBO/WECHAT)", required = true) @RequestParam(required = true) String thirdAccountType) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, BIND_SUCCESS);
        logger.info("绑定第三方账号请求参数=type:{},token:{}, openId:{},thirdAccountType:{}", type, token, openId, thirdAccountType);
        if (!CommonValidator.isStringsNotNull(type, token, openId, thirdAccountType)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean boole = usrService.bindThirdAccount(userId, openId, thirdAccountType);
        if (!boole) {//失败
            responseParameter.setStatus(Message.FAILURE);
            responseParameter.setMessage(BIND_FAILURE);
        }
        logger.info("绑定第三方账号响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 查看是否有消息
     *
     * @return
     */
    @ApiOperation(value = "查看是否有消息", notes = "返回字段: status 是否有消息0和1  ,sysMessageCount 系统消息个数，messageCount 个人消息个数,focusCount 粉丝关注消息个数,optCount 粉丝点赞消息个数 ")
    @RequestMapping(value = "/isExistMessage", method = RequestMethod.GET)
    public ResponseParameter isExistMessage(@ApiParam(value = "(必填)类型", required = true) @RequestHeader String type,
                                            @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("查看是否有消息=type:{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<String, Object> resultMap = usrService.findMessageCount(userId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultMap);
        responseParameter.setData(map);

        logger.info("查看是否有消息响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 检票员登录发送验证码
     *
     * @return
     */
    @ApiOperation(value = "(APP)检票员登录发送验证码", notes = "返回参数: </br>成功: </br>{status: SUCCESS, message：发送成功}" +
            "</br>失败: </br>{status: FAILURE, message：发送失败}</br>{status: FAILURE, message：验票员身份无效}")
    @RequestMapping(value = "/ticketSendSms", method = RequestMethod.POST)
    public ResponseParameter ticketSendSms(@ApiParam(value = "(必填)手机号码", required = true) @RequestHeader String mobile) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, SEND_SUCCESS);
        UsrTicketInspector usrTicketInspector = usrService.findMoblie(mobile);
        if (usrTicketInspector != null) {
            usrService.sendSms(mobile, "101952");
        } else {
            responseParameter = new ResponseParameter(Message.FAILURE, INSPECTOR_INVALID);
        }
        return responseParameter;
    }


    /**
     * 检票员登录
     *
     * @return
     */
    @ApiOperation(value = "(APP)检票员登录", notes = "返回参数: </br>成功: </br>{status: SUCCESS, </br>message: 登陆成功, </br>data: {</br>&nbsp;&nbsp;inspectorSn: aaa (用户SN, 用于二维码验票或者客户端扫码验票时 crowdfunding-sn-手机号(-为下划线))</br>&nbsp;}</br>}" +
            "</br>失败: </br>{status: FAILURE, message: 登陆失败}</br>{status: FAILURE, message: 验证码错误}")
    @RequestMapping(value = "/ticketLogin", method = RequestMethod.POST)
    public ResponseParameter ticketLogin(@ApiParam(value = "(必填)手机号码", required = true) @RequestHeader String mobile,
                                         @ApiParam(value = "(必填)验证码", required = true) @RequestHeader String captcha) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, LOGIN_FAILURE);
        if (!usrService.checkSms(mobile, captcha)) {
            logger.info("检票员登录响应参数= 验证码失败: captcha:{}", captcha);
            throw new CustomBizException(CAPTCHA_INVALID);
        }
        UsrTicketInspector usrTicketInspector = usrService.findMoblie(mobile);
        if (usrTicketInspector != null) {
            Map<Object, Object> map = new HashMap<>();
            map.put("inspectorSn", usrTicketInspector.getUserSerialNumber());
            responseParameter = new ResponseParameter(Message.SUCCESS, LOGIN_SUCCESS);
            responseParameter.setData(map);
        }
        return responseParameter;
    }

}
